<template>
	<view class="product-list">
		<view class="every-item" v-for="(item,index) in goodsList" :key="index" @tap="jumpGoodsDetail(item)">
			<navigator target="miniProgram" open-type="navigate" :app-id="shopAppId"
				:path="item.detailUrl" extra-data="" :version="version" hover-class="hoverbgfff">
			<dev-svg-image mode="image" :imageUrl="item.goodsImageUrl" width="320"
				height="224">
			</dev-svg-image>
			<view class="content-information">
				<view class="trade-name text-line ">
					{{item.title}}
				</view>
				<view class="sales-price">
					<text class="price">¥{{item.salePrice}}</text>
					<!-- <text class="sales-volume">销量{{item.salesNum}}</text> -->
				</view>
			</view>
			</navigator>
		</view>
	</view>
</template>

<script>
   
	export default {
		data() {
			return {
              goodsList:[],
              shopAppId: global.SHOP_APP_ID,
              version: global.IS_DEV?'trial':'release',  //''
			  pageCurrent:1,
			  pageSize:10,
			  loadingone:false,
			}
		},
		created() {//查询推荐商品的列表
			this.getGoodsByUserId(global.userInfo?global.userInfo.userId:null,false),
            this.shopAppId = global.IS_BSY_SHOP?'wx3cc80cbbb6a3b5f9':'wx3cc80cbbb6a3b5f9';
            this.version = global.IS_DEV?'trial':'release';
		},
		methods:{
			//上拉加载
			pullUpLoading(){
				this.pageCurrent += 1
				this.getGoodsByUserId(global.userInfo?global.userInfo.userId:null,true);
			},
			//查询商品列表
			getGoodsByUserId(userId,onReach){
				this.loadingone = true;
                if(global.IS_BSY_SHOP){
					this.$shopnew.get(global.apiUrls.getGoodsByUserId, 
                    {hisUserId:userId,
					pageCurrent:this.pageCurrent,
					pageSize:this.pageSize
					}).then(res => {
						if(res.data.code == 1000){
							let records = res.data.result.records;
							if(onReach){
								this.goodsList = this.goodsList.concat(records)
							}else{
								this.goodsList = records;
							}
							this.loadingone = false;
						}
					})
                    
                }else{
                    this.$shopnew.get(global.apiUrls.getGoodsByUserId, {hisUserId:userId}).then(res => {
                    	if(res.data.code == 1000){
                    		this.goodsList = res.data.result;
							this.loadingone = false;
                    	}
                    })
                }
				
			},
			//跳转商城的商品详情
			jumpGoodsDetail(item){
				//判断用户门店是否改变
                console.info("删除");
                return;
			}
		}
		
	}
</script>

<style lang="scss">
	.product-list {
		padding: 1rpx 42rpx;
		display: flex;
		//align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		.every-item {
			margin-top: 30rpx;
			width: 320rpx;
			box-shadow: 0px 15rpx 26rpx 0px rgba(219, 215, 215, 0.25);
			overflow: hidden;
			border-radius: 16rpx;
			background-color: #fff;
			.content-information{
				padding: 22rpx;
				.trade-name{
					//font-size: 30rpx;
					font-weight: 500;
					color: #333333;
					line-height: 42rpx;
				}
				.sales-price{
					margin-top: 20rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					.price{
						font-size: 26rpx;
						font-weight: 500;
						color: #F56767;
					}
					.sales-volume{
						font-size: 24rpx;
						font-weight: 400;
						color: #999999;
					}
				}
			}
		
		}
	}
</style>
